package com.qf.feign;

import com.qf.pojo.Customer;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * Feign 远程调用接口   （搜索微服务）
 *
 * fallback = SearchFeignImpl.class : 表示开启远程调用降级处理实现类功能
 * @author lixu
 */
@FeignClient(name = "QF-SEARCH",fallback = SearchFeignImpl.class)  //远程调用的微服务的名称
//@RequestMapping("/search")
public interface SearchFeign {


    /**
     * 搜索微服务
     *  1、
     * http://localhost:9002/search/list
     *  默认情况下 POST请求体中 name=xiaoxiao
     *
     *   2、@RequestParam(value = "name") String name
     *   http://localhost:9002/search/list?name=xiaoxiao
     *
     *   3、@
     *   http://localhost:9001/customer/feign/xiaoxiao
     */
    @GetMapping("/search/list")
    //public String list(@RequestParam(value = "name") String name);
    public String list(@RequestParam(value = "name") String name);
    /**
     * 搜索微服务

     *   3、@
     *   http://localhost:9001/customer/pathFeign/xiaoxiao
     */
    @GetMapping("/search/pathFeign/{name}")
    public String pathFeign(@PathVariable(value = "name") String name);

    /**
     * http://localhost:9001/search/pojo
     *  POST
     * @param customer
     * @return
     */
    @PostMapping("/search/pojo")
    String pojo(@RequestBody Customer customer);

    /**
     * 测试缓存
     * @param id
     * @return
     */
    @GetMapping("/search/findById/{id}")
    public Customer findById(@PathVariable(value = "id") Integer id);
}
